package com.demo.common.util.file;

import java.util.UUID;

/**
 * @function: 生成文件名字类
 * @Author: amayer
 * @Date: 2022/10/12
 */
public final class FileNameUtils {
    //获取文件后缀
    public static String getSuffix(String fileName){
        return fileName.substring(fileName.lastIndexOf("."));
    }

    //获取UID
    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-", "");
    }

    //生成新的文件名
    public static String getFileName(String fileOriginName){
        return getUUID() + getSuffix(fileOriginName);
    }
}
